#define  _CRT_SECURE_NO_WARNINGS 1class Solution {
public:

    int bitsum(int n)
    {
        int sum = 0;
        while (n)
        {
            int a = 0;
            a = n % 10;
            sum += a * a;
            n /= 10;
        }
        return sum;
    }
    bool isHappy(int n) {
        int fast = bitsum(n);
        int slow = n;
        while (fast != slow)
        {
            fast = bitsum(fast);
            fast = bitsum(fast);
            slow = bitsum(slow);
        }
        if (fast == 1)
        {
            return true;
        }
        else return false;
    }
};